﻿<%@ Page Title="" Language="C#" MasterPageFile="~/admincenter/AdminPage.master" AutoEventWireup="true"
    CodeFile="AddPost.aspx.cs" Inherits="admincenter_AddPost" %>
<%@ Register assembly="CKEditor.NET" namespace="CKEditor.NET" tagPrefix="CKEditor" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <title>Add a new Post | AdminPanel</title>
    <link href="<%= Page.ResolveClientUrl("~/css/jquery.tagsinput.css") %>" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="<%= Page.ResolveClientUrl("~/js/jquery.tagsinput.js") %>"></script>
    <script type="text/javascript" src="<%= Page.ResolveClientUrl("~/js/scripts/shCore.js") %>"></script>
    <script type="text/javascript" src="<%= Page.ResolveClientUrl("~/js/scripts/shBrushJScript.js") %>"></script>    
    <link href="<%= Page.ResolveClientUrl("~/css/syntaxhighlighter/shCore.css")%>" rel="stylesheet" type="text/css" />
    <link href="<%= Page.ResolveClientUrl("~/css/syntaxhighlighter/shThemeEclipse.css")%>" rel="stylesheet" type="text/css" />
    <script type="text/javascript">        SyntaxHighlighter.all();</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div class="row">
        <div class="col-lg-12">
            <h1>Add a new post</h1>
            <ol class="breadcrumb">
                <li><i class="fa fa-dashboard"></i>  Bảng điều khiển</li>
                <li class="active"><i class="fa fa-table"></i>  Add a new post</li>
            </ol>
        </div>                                        
        <div class="col-lg-9">                                             
            <div class="form-group">
                <label>Mã bài viết / Id Post</label>
                <p>
                    <asp:TextBox CssClass="form-control" runat="server" ID="tbId" placeholder="Mã bài viết"
                        MaxLength="100"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" SetFocusOnError="True"
                        ControlToValidate="tbId" Display="Dynamic" ErrorMessage="(*) Chưa nhập dữ liệu"
                        ValidationGroup="groupAddUpdatePT"></asp:RequiredFieldValidator>
                </p>                
                <label>Tiêu đề / Title</label>
                <p>
                    <asp:TextBox CssClass="form-control" runat="server" ID="tbTieude" placeholder="Tiêu đề bài viết"
                        MaxLength="100"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" SetFocusOnError="True"
                        ControlToValidate="tbTieude" Display="Dynamic" ErrorMessage="(*) Chưa nhập dữ liệu"
                        ValidationGroup="groupAddUpdatePT"></asp:RequiredFieldValidator>                 
                </p>                
                <label>Chuyên mục / Id Category</label>
                <p>
                    <asp:DropDownList CssClass="form-control" runat="server" ID="ddlCategory" ></asp:DropDownList>                    
                </p>
                <label>Mô tả / Description</label>
                <p>
                    <asp:TextBox ID="tbMota" runat="server" Rows="4" CssClass="form-control" TextMode="MultiLine" 
                    placeholder="Tóm tắt bài viết" ToolTip="Mô tả bài viết"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" SetFocusOnError="True"
                        ControlToValidate="tbMota" Display="Dynamic" ErrorMessage="(*) Chưa nhập dữ liệu"
                        ValidationGroup="groupAddUpdatePT"></asp:RequiredFieldValidator>
                </p>
                <label>Nội dung / Content</label>
                <p>
                    <CKEditor:CKEditorControl runat="server" ID="ckeditor1" Language="vi"></CKEditor:CKEditorControl>
                </p>
                <label>Ảnh bìa / Image Panorama (<asp:Label runat="server" ID="lbValidateAb"></asp:Label>)</label>
                <p>
                    <asp:FileUpload runat="server" ID="fuAnhbia" CssClass="form-control"/>
                </p>
                <label>Ảnh đại diện / Image Thumbnail (<asp:Label runat="server" ID="lbValidateTb"></asp:Label>)</label>
                <p>
                    <asp:FileUpload runat="server" ID="fuAnhDaidien" CssClass="form-control"/>
                </p>
                <label>Nguồn / Source</label>
                <p>
                    <asp:TextBox ID="tbNguon" runat="server" CssClass="form-control" 
                    placeholder="Nguồn trích dẫn" ToolTip="Nguồn trích dẫn"></asp:TextBox>
                </p>
                <label>Link tải về / Link Download</label>
                <p>
                    <asp:TextBox ID="tbLinkDown" runat="server" CssClass="form-control" 
                    placeholder="Đường dẫn tải về" ToolTip="Đưỡng dẫn tải về"></asp:TextBox>
                </p>
                <label>Thẻ Tags / Tags</label>
                <p>
                    <asp:TextBox ID="tbTags" runat="server" CssClass="form-control" 
                    placeholder="Tag" ToolTip="Tag" Text=""></asp:TextBox>
                </p>
                <label>Sử dụng</label>
                <p>
                    <asp:CheckBox CssClass="form-control" runat="server" ID="cbTrangThai" ToolTip="Trạng thái sử dụng" />
                </p>
                <label>Phản hồi / Feedback</label>
                <p>
                    <asp:TextBox ID="tbPhanhoi" runat="server" Rows="4" CssClass="form-control" TextMode="MultiLine" 
                    placeholder="Phản hồi về bài viết" ToolTip="Phản hồi về bài viết"></asp:TextBox>
                </p>
                <p><button type="reset" class="btn btn-default">Xóa</button>
                    <asp:Button runat="server" CssClass="btn btn-primary" ID="btnThemvao" Text="Thêm vào"
                                        OnClick="btnThemvao_OnClick"/></p>
            </div>                
        </div>      
        <div class="col-lg-3">
            <asp:Literal runat="server" ID="litResult" EnableViewState="False"></asp:Literal>
        </div>        
    </div>
    <script src="<%= Page.ResolveClientUrl("~/js/fixie.common.js") %>" type="text/javascript"></script>
    <script type="text/javascript">
        // Process for tag input at textbox tbTags
        var tagInput = null;
        window.onload = function () {
            try {
                tagInput = document.getElementById('<%= this.tbTags.ClientID %>');
                $(function () {
                    $('#' + '<%= this.tbTags.ClientID %>').tagsInput({ width: 'auto' });
                });
            } catch (e) {
                tagInput = null;
            }
        };

        var validFilesTypes = ["gif", "png", "jpg", "jpeg"];
        
        function ValidateFile() {
            var file = document.getElementById("<%= fuAnhbia.ClientID%>");
            var label = document.getElementById("<%= lbValidateAb.ClientID%>");
            var path = file.value;
            var ext = path.substring(path.lastIndexOf(".") + 1, path.length).toLowerCase();
            var isValidFile = false;
            for (var i = 0; i < validFilesTypes.length; i++) {
                if (ext == validFilesTypes[i]) {
                    isValidFile = true;
                    break;
                }
            }
            if (!isValidFile) {
                label.style.color = "red";
                label.innerHTML = "Invalid File. Please upload a File with" +
         " extension:\n\n" + validFilesTypes.join(", ");
            }
            return isValidFile;
        }

        // function 
    </script>
</asp:Content>
